<?php
namespace App\Models\Base;

use Illuminate\Database\Eloquent\Relations\MorphTo;

class Photo extends BaseModel
{
    protected $table = 'beesoft_photos';
    protected $fillable = [
        'title',
        'photos',
    ];

    public function morph(): MorphTo
    {
        return $this->morphTo();
    }

    // 属性
    public function setPhotosAttribute($photos) {
        if ( is_array($photos) ) {
            $this->attributes['photos'] = json_encode($photos);
        }
    }
    public function getPhotosAttribute($photos) {
        return json_decode($photos, true);
    }
}
